/*
 *  KeyLok.h
 *
 *  Created by Pat Long (plong0) on 08/04/09.
 *  Copyright 2009 Tangible Interaction Inc. All rights reserved.
 *
 */
#ifndef _TI_KEYLOK
#define _TI_KEYLOK

#include "ofMain.h"

#include "KEYERROR.H"    // KEY-LOK error codes
#include "KEYCOMMANDS.H" // KEY-LOK command codes

extern "C" {
	extern unsigned long KFUNC(unsigned, unsigned, unsigned, unsigned);
}

// wrapper for the KeyLok functions
class KeyLok{
	private:
		unsigned validateCode1, validateCode2, validateCode3, clientIDCode1, clientIDCode2, readCode1, readCode2, readCode3, writeCode1, writeCode2, writeCode3;
		unsigned ReturnValue1, ReturnValue2;
	
		void KTASK(unsigned CommandCode, unsigned Argument2, unsigned Argument3, unsigned Argument4);
		unsigned RotateLeft(unsigned Target, int Counts);
	
	public:
		KeyLok();
		~KeyLok();
	
		bool isConnected();
	// TODO: implement the rest of the Key-Lok functionality
	
		void setValidateCode(int validateCode, int codeNum=1);
		void setValidateCodes(int validateCode1, int validateCode2, int validateCode3);
		void setClientIDCode(int clientIDCode, int codeNum=1);
		void setClientIDCodes(int clientIDCode1, int clientIDCode2);
		void setReadCode(int readCode, int codeNum=1);
		void setReadCodes(int readCode1, int readCode2, int readCode3);
		void setWriteCode(int writeCode, int codeNum=1);
		void setWriteCodes(int writeCode1, int writeCode2, int writeCode3);
	
};

#endif
